home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / zs20a.zip / UNZIP.PA_ / UNZIP.PAS
Pascal/Delphi Source File  |  1994-11-21  |  13KB  |  171 lines

  1. (***************************************************************************************************************************)
  2. (*                                                                                                                         *)
  3. (*        Zip Studio 2.0 COPYRIGHT 1993, 1994 Denis CHEVRON                                                                    *)
  4. (*    Source File: UNZIP.PAS                                                                                               *)
  5. (*    Description: Pascal Source file to encapsulate the UZDLL20.DLL file to provide the functionality to                  *)
  6. (*                 Borland Pascal developers.  This version was written for BP v7.0 but contains nothing that              *)
  7. (*                 would prohibit its adaption to earlier versions of Borland's Pascal for Windows compilesr.              *)
  8. (*    Date:        Mon Nov 7 21:45:05 1994                                                                                 *)
  9. (*    Author:      Brad Stowers, CIS: 72733,3374                                                                           *)
  10. (*                               Internet: bstowers@cybernetics.net                                                        *)
  11. (*                                                                                                                         *)
  12. (***************************************************************************************************************************)
  13. (*                                                                                                                         *)
  14. (*        To Zip, Put UZDLL20.DLL in your applications directory and add this unit to your USES clause.                        *)
  15. (*    By using this unit, you are NOT required to use LoadLibrary and FreeLibrary.  Simply call these parameters as you    *)
  16. (*    would any other unit.                                                                                                *)
  17. (***************************************************************************************************************************)
  18.  
  19. unit UnZip;
  20.  
  21. interface
  22.  
  23. uses WinTypes;
  24.  
  25. (***************************************************************************************************************************)
  26. (* The UNZIP.INC file contains constants that will be useful when calling these functions.  By including it here, you      *)
  27. (* don't have to include it in your own program.  Do have a look at it so that you will know what is available.            *)
  28. (***************************************************************************************************************************)
  29.  
  30. {$I UNZIP.INC}
  31.  
  32. (* Initialization function *)
  33.   procedure UnzipInit(YourName, Password: pChar);              { Required.  If you aren't a registered user, set         }
  34.                                                                { YourName to 'TEST' and Password to ''                   }
  35.  
  36. (* Interface setting functions *)
  37.   function  UnzipSetMsgBoxTitle(NewTitle: pChar): boolean;        { Set the replace dialog box title ( default = "Replace...") }
  38.   procedure UnzipSetLanguage(Language: word);                   { Set the language for the replace dialog box }
  39.   function  UnzipSetReceivingWindow(Wnd: hWnd): boolean;        { Set the window for notification messages }
  40.   procedure UnzipSetBackgroundMode(BackGroundMode: boolean);    { if TRUE, activate the multitask mode ( default ) }
  41.   function  UnzipSetReplaceText(DialogTitle,                    { Set the replace dialog box labels, used     }
  42.                                 DialogText,                     { with the LANGUAGE_NONE mode and the         }
  43.                                 YesBtn,                         { ZN_REPLACE notification message..           }
  44.                                 NoBtn,
  45.                                 AlwaysBtn,
  46.                                 NeverBtn: pChar): boolean;
  47.  
  48. (* Information functions ( Zip ) *)
  49.   function  IsFileInZip(ZIPFileName,
  50.                         FileName: pChar): boolean;              { Return TRUE if the file (wildcards ok) is in the ZIP file }
  51.   function  CountFileInZip(FileName: pChar): integer;           { Return number of files in this Zip File }
  52.   function  GetFileNameFromZip(FileName: pChar;
  53.                                FileNumber: integer): pChar;     { Return the name of the iFileNumber file in this Zip File }
  54.   function  GetZFileOriginalSize(ZIPFilename,
  55.                                  FileName: pChar): LongInt;     { Return the not compressed size of szFileName in octets. }
  56.   function  GetZFileCompressedSize(ZIPFileName,
  57.                                    FileName: pChar): LongInt;   { Return the compressed size of szFileName in octets. }
  58.   function  GetZFileDate(ZIPFileName, FileName: pChar): pChar;  { Return the date of a file in a Zip }
  59.   function  GetZFileTime(ZIPFileName, FileName: pChar): pChar;  { Return the time of a file in a Zip }
  60.   function  GetZCompressedMethod(ZIPFileName,
  61.                                  FileName: pChar): Word;        { Return the Zip method for a file ( ZMETHOD_* ) }
  62.   { Changed for version 2.0 }
  63.   function  IsThisFileAZipFile(FileName: pChar;
  64.                                QuickTest: boolean): boolean;    { Return TRUE if this file seems to be a zip file }
  65.   function  IsFileUnzipable(FileName: pChar): boolean;          { Return TRUE if this file name can be reproduce under DOS }
  66.   function  GetZipCommentLength(FileName: pChar): word;         { Return the size of the zip file comment in octets }
  67.   function  GetZipComment(FileName, Buffer: pChar): boolean;    { Put the zip comment in buffer }
  68.   { New for version 2.0 }
  69.   function  GetZFileIsEncrypted(ZIPFileName,
  70.                                 FileName: pChar): boolean;      { Checks if <FileName> in <ZIPFileName> }
  71.                                                                 { ZIP file is encrypted.                }
  72.   { New for version 2.0 }
  73.   function  GetZFileIsDir(ZIPFileName,                          { Is <FileName> a directory entry in <ZIPFileName>? }
  74.                           FileName: pChar): boolean;
  75.   { New for version 2.0 }
  76.   function  GetZFileFullInfos(ZIPFileName, FileName,            { Fill <Result> with info for <FileName> in <ZIPFileName> }
  77.                               Result: pChar): boolean;          { Result must be at least 456 bytes.  ';' is used to      }
  78.                                                                 { separate these values:  filename, original size,        }
  79.                                                                 { compressed size, file date, file time, and compression  }
  80.                                                                 { method.  EX: 'MYFILE.ET;1254;984;01/21/94;04:12pm;8'    }
  81.                                                                 { Returns false if couldn't retrieve data.                }
  82.   { New for version 2.0 }
  83.   function  GetZList(ZIPFileName: pChar;
  84.                      ListWnd: hWnd;
  85.                      From: word;
  86.                      SortMode: integer;
  87.                      BackGnd: boolean): integer;                { Retrieve filenames from ZIP file. }
  88.   { New for version 2.0 }
  89.   function  UnzipSortZList(ListWnd: hWnd;
  90.                            SortMode: integer;
  91.                            BackGnd: boolean): boolean;          { Resort the list. }
  92.  
  93.  
  94. (* Information functions ( General ) *)
  95.   function  DoesFileExist(FileName: pChar): boolean;            { True if this file exists }
  96.   function  GetShortFileName(FileName: pChar): pChar;           { Return filename without any path }
  97.   function  GetPathFromFileName(FileName: pChar): pChar;        { Return the path without the file name }
  98.   function  IsFileNameInFilter(FileName, Mask: pChar): boolean; { Return TRUE if filename is in specified filter }
  99.  
  100. (* Extraction functions *)
  101.   function  ExtractZipFiles(FileName, Mask,DestDir: pChar;
  102.                            Overwrite: word;
  103.                            CreateDir: word): word;              { Go get them }
  104.   function  GetQueryFlag: integer;                              { Return the overwrite mode the user asked for }
  105.   { New for version 2.0 }
  106.   procedure UnzipCancel(Cancel: boolean);                       { If <Cancel> is TRUE, the Unzip or View process will  }
  107.                                                                 { stop as soon as possible.                            }
  108.                                                                 { VERY IMPORTANT:  This function must be called with   }
  109.                                                                 { <Cancel> set to FALSE before any Unzip function call }
  110.                                                                 { (except for the inforamation functions).             }
  111.   { New for version 2.0 }
  112.   function  GetZipItem(ListWnd: hWnd;
  113.                        Index: integer;
  114.                        Item: pZipItem): boolean;                { pZipItem declared in UNZIP.INC }
  115.   { New for version 2.0 }
  116.   function  ZipJoin(ParentWnd: hWnd;
  117.                     Name, DestDir: pChar;
  118.                     SendMsg: boolean;
  119.                     Title, Msg: pChar): integer;                { Rebuild split files into ZIP file }
  120.  
  121. (* View function *)
  122.   function  ViewFileFromZip(ZipFile, Mask: pChar;
  123.                            TextOnly: boolean): boolean;         { View one or several files in a Zip }
  124.  
  125. (* Encryption functions *)
  126.   { New for version 2.0 }
  127.   function  UnzipSetPassword(Password: pChar): boolean;         { To set password before Extract or View call }
  128.   { New for version 2.0 }
  129.   procedure SetAskPassword(Ask: boolean);                       { If <Ask> is FALSE, Zip Studio won' t ask the user for }
  130.                                                                 { a password. (Default is TRUE).                        }
  131.  
  132.  
  133. implementation
  134.  
  135.   procedure UnzipInit;                                         external 'UZDLL20';
  136.   function  UnzipSetMsgBoxTitle;                               external 'UZDLL20';
  137.   procedure UnzipSetLanguage;                                  external 'UZDLL20';
  138.   function  UnzipSetReceivingWindow;                           external 'UZDLL20';
  139.   procedure UnzipSetBackgroundMode;                            external 'UZDLL20';
  140.   function  UnzipSetReplaceText;                               external 'UZDLL20';
  141.   function  IsFileInZip;                                       external 'UZDLL20';
  142.   function  CountFileInZip;                                    external 'UZDLL20';
  143.   function  GetFileNameFromZip;                                external 'UZDLL20';
  144.   function  GetZFileOriginalSize;                              external 'UZDLL20';
  145.   function  GetZFileCompressedSize;                            external 'UZDLL20';
  146.   function  GetZFileDate;                                      external 'UZDLL20';
  147.   function  GetZFileTime;                                      external 'UZDLL20';
  148.   function  GetZCompressedMethod;                              external 'UZDLL20';
  149.   function  IsThisFileAZipFile;                                external 'UZDLL20';
  150.   function  IsFileUnzipable;                                   external 'UZDLL20';
  151.   function  GetZipCommentLength;                               external 'UZDLL20';
  152.   function  GetZipComment;                                     external 'UZDLL20';
  153.   function  DoesFileExist;                                     external 'UZDLL20';
  154.   function  GetShortFileName;                                  external 'UZDLL20';
  155.   function  GetPathFromFileName;                               external 'UZDLL20';
  156.   function  IsFileNameInFilter;                                external 'UZDLL20';
  157.   function  ExtractZipFiles;                                   external 'UZDLL20';
  158.   function  GetQueryFlag;                                      external 'UZDLL20';
  159.   function  ViewFileFromZip;                                   external 'UZDLL20';
  160.   function  GetZFileIsEncrypted;                               external 'UZDLL20';
  161.   procedure UnzipCancel;                                       external 'UZDLL20';
  162.   function  GetZList;                                          external 'UZDLL20';
  163.   function  UnzipSortZList;                                    external 'UZDLL20';
  164.   function  GetZipItem;                                        external 'UZDLL20';
  165.   function  ZipJoin;                                           external 'UZDLL20';
  166.   function  UnzipSetPassword;                                  external 'UZDLL20';
  167.   procedure SetAskPassword;                                    external 'UZDLL20';
  168.   function  GetZFileIsDir;                                     external 'UZDLL20';
  169.   function  GetZFileFullInfos;                                 external 'UZDLL20';
  170. end.
  171.